import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'navigation_controller.dart';
import 'widget/custom_bottom_nav_widget.dart';
import '../home/landing_page.dart';
import '../communal/community_page.dart';
import '../chat/messaging_page.dart';
import '../my/profile_page.dart';

/// 主屏幕组件
/// 使用GetX进行页面逻辑分离
class PrimaryScreen extends GetView<PrimaryScreenController> {
  const PrimaryScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        children: [
          // 页面内容
          Obx(() {
            final currentTabIndex = controller.currentTabIndex.value;
            final screenPages = [
              const LandingPage(),
              const CommunityPage(),
              const MessagingPage(),
              const ProfilePage(),
            ];
            return screenPages[currentTabIndex];
          }),
          // 底部导航栏 - 定位在底部
          Positioned(
            left: 0,
            right: 0,
            bottom: 0,
            child: const CustomBottomNavWidget(),
          ),
        ],
      ),
    );
  }
}
